<%
layout("/layouts/platform.html"){
%>
	<header class="header navbar bg-white shadow">
		<div class="btn-group tool-button" style="padding:8px 0">
			<table>
           		<tbody>
           			<tr>
                  		<td>
                       		<input type="text" id="nameStr" name="nameStr" onclick="this.value=''" class="form-control" placeholder="名称" autofocus>
                        </td>
                        <td style="padding-left: 5px;">
                            <button id="searchBtn" type="button" class="btn btn-default"><i class="fa fa-search"></i>&nbsp;查询</button>
                      	</td>
                        </tr>
                    </tbody>
            </table>
		</div>
	    <div class="pull-right offscreen-right">
	         <a class="btn btn-default navbar-btn" href="${base}/platform/train/lumpproduct/add" data-toggle="modal" data-target="#addModal" ><i class="fa fa-plus"></i>&nbsp;新增</a>
		</div>
	</header>
	<div class="panel-body" style="padding-top: 70px;">
		<div class="box">
			<div class="box-body">
				<div class="col-sm-12">
					<div class="row">
						<table class="table table-bordered table-hover mg-t datatable" style=" white-space: nowrap;text-overflow: ellipsis;">
					   		<thead>
					            <tr>
									<th>主体</th>
									<th>片区</th>
									<th>名称</th>
									<th>编码</th>
									<th>培训项目</th>
									<th>培训方式</th>
									<th>接送方式</th>
									<th>产品规格</th>
									<th>价格</th>
									<th>付款说明</th>
									<th>服务说明</th>
									<th>状态</th>
									<th>操作</th>
    	        		</table>
	    			</div>
				</div>
			</div>
		</div>
	</div>
	<div id="dialogDelete" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
	    <div class="modal-dialog">
	        <div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	                <h4 class="modal-title">删除</h4>
	            </div>
	            <div class="modal-body">
	                <div class="row">
	                    <div class="col-xs-12">
	                        确定删除该数据吗？ <br/>
	                    </div>
	                </div>
	            </div>
	            <div class="modal-footer">
	                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	                <button id="ok" type="button" class="btn btn-primary" data-loading-text="正在删除...">确定</button>
	            </div>
	        </div>
	    </div>
	</div>
	<!-- 修改-->
	<div id="editModal" class="modal fade bs-modal-sm"   tabindex="-3" role="dialog" aria-hidden="true">
	    <div id="editModalDialog" class="modal-dialog " >
	        <div class="modal-content">
	        
	        </div>
	    </div>
	</div>
	<!-- 新增-->
	<div id="addModal" class="modal fade bs-modal-sm"   tabindex="-3" role="dialog" aria-hidden="true">
	    <div id="addModalDialog" class="modal-dialog " >
	        <div class="modal-content">
	        
	        </div>
	    </div>
	</div>
<script language="JavaScript">
    var datatable;
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching": false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "scrollX": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/platform/train/lumpproduct/data",
                "type": "post",
                "data": function (d) {
                	d.name=$('#nameStr').val();
                }
            },
            "order": [[0, "desc"]],
            "columns": [
				{"data": "company_name", "bSortable": true},
				{"data": "region_name", "bSortable": true},
				{"data": "name", "bSortable": true},
				{"data": "code", "bSortable": true},
				{"data": "project_name", "bSortable": true},
				{"data": "train_mode", "bSortable": true},
				{"data": "shuttle_mode", "bSortable": true},
				{"data": "specs", "bSortable": true},
				{"data": "price", "bSortable": true},
				{"data": "payment", "bSortable": true},
				{"data": "remark", "bSortable": true},
				{"data": "state", "bSortable": true}
            ],
            "columnDefs": [
              	{
                	"render": function (data, type, row) {
                       	if(data=='0'){
                       		return "计时";
                       	}else {
                       		return "学时包干";
                       	}
                   	 },
                    "targets": 5
              	},
              	{
                	"render": function (data, type, row) {
                       	if(data=='0'){
                       		return "无接送";
                       	}else if(data=='1'){
                       		return "班车接送";
                       	}else{
                       		return "定点接送";
                       	}
                   	 },
                    "targets": 6
              	},
           	 	{
                	"render": function (data, type, row) {
                       	if(data==1){
                       		return "启用";
                       	}else if(data==0){
                       		return "未启用";
                       	}else{
                       		return "已作废";
                       	}
                   	 },
                    "targets": 11
              	},
                {
                    "render": function (data, type, row) {
                        return '<div>'
						 + '<a class="btn btn-xs btn btn-default " href="${base}/platform/train/lumpproduct/edit/' + row.id + '" data-toggle="modal" data-target="#editModal"><i class="fa fa-edit"></i>&nbsp;修改</a> '
						 + '<a class="btn btn-xs btn btn-default " href="javascript:;" onclick="del(\''+ row.id+ '\')"><i class="glyphicon glyphicon-trash"></i>删除</a>'
						 + '</div>';
                    },
                    "targets": 12
                }
            ]
        });
        $("#searchBtn").on('click', function () {
            datatable.ajax.reload();
        });
    }
    function del(id) {
        var dialog = $("#dialogDelete");
        dialog.modal("show");
        dialog.find("#ok").unbind("click");
        dialog.find("#ok").bind("click", function (event) {
            $.post("${base}/platform/train/lumpproduct/delete/" + id, {}, function (data) {
                if (data.code == 0) {
                    datatable.ajax.reload(null,false);
                } else {
                    Toast.error(data.msg);
                }
                dialog.modal("hide");
            }, "json");
        });
    }
    $(function () {
        initDatatable();
        $("#addModal").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
        });
		$("#editModal").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
        });
    });
    
    
</script>

<%}%>
